/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.basic.pages.system;

import com.eelpo.cmmp.basic.dao.vo.SystemConfig;
import com.eelpo.cmmp.core.wicket.panel.container.SearchPanel;

import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.PropertyModel;

/**
 * <pre>
 * 系统配置管理查询参数面板
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class SystemConfigSearchPanel extends SearchPanel {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 4897791468268434575L;

	public SystemConfigSearchPanel(String id, SystemConfig config) {
		super(id);

		add(renderFeedbackPanel("feedback"));

		renderConfigKeyTextField(config);
		renderConfigValueTextField(config);
		renderDescriptionTextField(config);
		renderAddButton();
	}

	public void renderConfigKeyTextField(SystemConfig config) {
		add(new TextField<String>("txtConfigKey", new PropertyModel<String>(config, "configKey")));
	}

	public void renderConfigValueTextField(SystemConfig config) {
		add(new TextField<String>("txtConfigValue", new PropertyModel<String>(config, "configValue")));
	}

	public void renderDescriptionTextField(SystemConfig config) {
		add(new TextField<String>("txtDescription", new PropertyModel<String>(config, "description")));
	}

	private void renderAddButton() {
		Link<Void> lnkAdd = new Link<Void>("btnAdd") {
			private static final long serialVersionUID = -940868358118439402L;

			public void onClick() {
				setResponsePage(new AddOrEditSystemConfig());
			}
		};
		add(lnkAdd);
	}

}
